package caiwei.android.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import caiwei.android.R;

/**
 * 呈现Activity之间相互传递数据和返回信息
 * 
 * @author caiwei
 * @date2012-3-19
 * @version 1.0
 */
public class ActivityIntentPresent extends ActivityGridBaseActivityFirst
{
	private EditText mEditText;
	private Intent mIntent;
	private static final int RESULTCODE = 4321;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		LinearLayout _LinearLayout = new LinearLayout(this);
		_LinearLayout.setOrientation(LinearLayout.VERTICAL);
		LayoutParams _LayoutParams = new LayoutParams(
				LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.FILL_PARENT);
		LayoutParams _LayoutParamsItem = new LayoutParams(
				LinearLayout.LayoutParams.FILL_PARENT,
				LinearLayout.LayoutParams.WRAP_CONTENT);
		_LinearLayout.setLayoutParams(_LayoutParams);
		mEditText = new EditText(this);
		mEditText.setLayoutParams(_LayoutParamsItem);
		mIntent = getIntent();
		mEditText.setText("++++++");
		mEditText.setText(mIntent.getStringExtra("present"));
		Button _BackButton = new Button(this);
		_BackButton.setLayoutParams(_LayoutParamsItem);
		_BackButton.setText(R.string.btnBack);
		_LinearLayout.addView(mEditText);
		_LinearLayout.addView(_BackButton);
		setContentView(_LinearLayout);
		_BackButton.setOnClickListener(new OnClickListener()
		{

			@Override
			public void onClick(View v)
			{
				String _BackValue = mEditText.getText().toString();
				mIntent.putExtra("back", _BackValue);
				setResult(RESULTCODE, mIntent);
				finish();
			}
		});
	}
}
